package tsb.com.html5.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import tsb.com.html5.exception.GenericException;

public class CommonInterceptor implements HandlerInterceptor {

	static Logger logger = Logger.getLogger(CommonInterceptor.class);
	/*static {
		BasicConfigurator.configure();
	}*/
	
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		// TODO Auto-generated method stub
//		logger.info("Before handling the request");
		
		logger.debug("********************************************");
		logger.debug(">>>>>> preHandle >>>>>>"+request.getRequestURL());
		logger.debug(">>>>>> preHandle >>>>>>"+request.getQueryString());
		logger.debug("********************************************");
		return true;
	}

	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO Auto-generated method stub
//		logger.info("After handling the request");
//		logger.debug(">>>>>> postHandle >>>>>>"+request.getSession().getId());
		//super.postHandle(request, response, handler, modelAndView);
	}

	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
	throws Exception {
		// TODO Auto-generated method stub
//		logger.info("After rendering the view");
//		logger.debug(">>>>>> afterCompletion >>>>>>"+request.getSession().getId());
		//super.afterCompletion(request, response, handler, ex);
	}
}